home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 301-325 / disk_319 / cnewssrc / cnews.src.lzh / libc / nfclose.c < prev    next >
C/C++ Source or Header  |  1980-01-01  |  518b  |  24 lines

  1. /*
  2.  * nfclose(stream) - flush the stream, fsync its file descriptor and
  3.  * fclose the stream, checking for errors at all stages.  This dance
  4.  * is needed to work around the lack of Unix file system semantics
  5.  * in Sun's NFS.  Returns EOF on error.
  6.  */
  7.  
  8. #include <stdio.h>
  9.  
  10. int
  11. nfclose(stream)
  12. register FILE *stream;
  13. {
  14.     register int ret = 0;
  15.  
  16.     if (fflush(stream) == EOF)
  17.         ret = EOF;
  18.     if (fsync(fileno(stream)) < 0)        /* may get delayed error here */
  19.         ret = EOF;
  20.     if (fclose(stream) == EOF)
  21.         ret = EOF;
  22.     return ret;
  23. }
  24.